<template>
  <div class="app-container">
    <template>
      <div class="hidden-md-and-up">
        <el-alert title="如若不适应手机端操作，建议使用电脑操作" type="warning" />
      </div>
    </template>
    <div class="table-container">
      <div style="padding-bottom:20px; display: flex;">
        <div style="width: 260px;">
          <label>成果名称</label>
          <el-input v-model="search.name" size="medium" placeholder="输入成果名称" style="width: 160px;" />
        </div>
        <div style="width: 260px;">
          <label>第一作者</label>
          <el-input v-model="search.firstAuthor" size="medium" placeholder="输入第一作者" style="width: 160px;" />
        </div>
        <div style="width: 220px; ">
          <label>成果形式</label>
          <el-select v-model="search.resultForm" clearable style="width: 160px;" placeholder="请选成果形式">
            <el-option label="研究" value="研究" />
            <el-option label="咨询报告" value="咨询报告" />
          </el-select>
        </div>
        <div style="width: 220px; margin-left: 20px;">
          <label>级别</label>
          <el-select v-model="search.level" clearable style="width: 160px;" placeholder="请选择级别">
            <el-option label="国家级" value="国家级" />
            <el-option label="部级" value="部级" />
            <el-option label="省级" value="省级" />
            <el-option label="厅级" value="厅级" />
            <el-option label="市级" value="市级" />
          </el-select>
        </div>
      </div>
      <div style="padding-bottom:20px; display: flex;">
        <div style="width: 600px; display: flex; align-items: center; gap: 8px">
          <label>采纳/签批时间</label>
          <div style="flex: 1">
            <el-date-picker
              v-model="search.beginTime"
              type="date"
              placeholder="起始时间"
              format="yyyy-MM-dd"
              value-format="yyyy-MM-dd"
            />
          </div>
          <span style="flex-shrink: 0; margin: 0 4px">-</span>
          <div style="flex: 1">
            <el-date-picker
              v-model="search.endTime"
              type="date"
              placeholder="结束时间"
              format="yyyy-MM-dd"
              value-format="yyyy-MM-dd"
              style="width: 100%"
            />
          </div>
        </div>
        <div style="width: 220px; margin-left: 20px;">
          <label>状态</label>
          <el-select v-model="search.status" size="medium" placeholder="请选择状态" style="width: 160px;" @change="statusChange">
            <el-option label="全部" value="" />
            <el-option label="草稿" value="草稿" />
            <el-option label="待院级审核" value="待院级审核" />
            <el-option label="被院级退回" value="被院级退回" />
            <el-option label="待校级审核" value="待校级审核" />
            <el-option label="被校级退回" value="被校级退回" />
            <el-option label="审核通过" value="审核通过" />
          </el-select>
        </div>
        <div style="margin-left: 20px;" />
        <el-button type="success" size="medium" plain icon="el-icon-download" @click="excel_dialog = true">导出</el-button>
      </div>
      <el-table
        v-loading="paperListLoading"
        :data="paperList"
        element-loading-text="Loading"
        border
        fit
      >
        <el-table-column type="selection" align="center" width="55" />
        <!-- <el-table-column align="center" label="序号" width="55">
          <template slot-scope="scope">
            {{ scope.$index+1 }}
          </template>
        </el-table-column> -->
        <el-table-column align="center" label="成果名称" min-width="120">
          <template slot-scope="scope">
            {{ scope.row.name }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="第一作者" min-width="100">
          <template slot-scope="scope">
            {{ scope.row.firstAuthor }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="成果形式" min-width="100">
          <template slot-scope="scope">
            {{ scope.row.resultForm }}
          </template>
        </el-table-column>
        <el-table-column align="center" label="级别" min-width="100">
          <template slot-scope="scope">
            {{ scope.row.level }}
          </template>
        </el-table-column>
        <el-table-column align="center" prop="adoptionTime" label="采纳/签批时间" sortable min-width="120" />
        <el-table-column
          align="center"
          label="状态"
          min-width="70"
        >
          <template slot-scope="scope">
            <el-tag :type="scope.row.status | statusFilter">{{ scope.row.status }}</el-tag>
            <el-tag v-if="scope.row.status === '被院级退回' || scope.row.status === '被校级退回'" type="warning">{{ scope.row.reason }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column align="center" label="分数" min-width="60">
          <template slot-scope="scope">
            <el-tag>{{ scope.row.score }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column align="center" label="操作" width="230">
          <template slot-scope="scope">
            <el-popover
              :ref="`popoverpass-${scope.$index}`"
              placement="top"
              width="160"
            >
              <p>确认通过吗？该操作不可撤销</p>
              <div style="text-align: right; margin: 0">
                <el-button size="mini" type="text" @click="scope._self.$refs[`popoverpass-${scope.$index}`].doClose()">取消</el-button>
                <el-button type="primary" size="mini" @click="thesis_pass(scope.$index, scope.row)">确定</el-button>
              </div>
            </el-popover>
            <el-button
              size="mini"
              @click="open_infoview_dialog(scope.row)"
            >
              查看
            </el-button>
            <el-button
              size="mini"
              type="danger"
              @click="thesis_back(scope.row)"
            >
              退回
            </el-button>
            <el-button
              v-popover="`popoverpass-${scope.$index}`"
              size="mini"
              type="success"
            >
              通过
            </el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="block">
        <el-pagination
          background
          :current-page="p1_page"
          :page-sizes="[10,20,40,80]"
          :page-size="p1_size"
          layout="total, sizes, prev, pager, next, jumper"
          :total="p1_total"
          @size-change="p1_sizechange"
          @current-change="p1_currentchange"
        />
        <!-- @size-change="handleSizeChange"
          @current-change="handleCurrentChange" -->
        <!-- 使用了size-change和current-change事件来处理页码大小和当前页变动时候触发的事件。 -->
      </div>
      <el-dialog title="信息总览" :visible.sync="infoview_dialog" width="75%">
        <el-collapse v-model="activeNames">
          <el-collapse-item name="1">
            <template slot="title">
              <div class="el-descriptions__title">论文信息</div>
            </template>
            <el-descriptions :column="2" size="medium" border :label-style="{width:'25%'}" :content-style="{width:'25%'}">
              <el-descriptions-item label="录入人">
                {{ infoview1.enteredName }}
              </el-descriptions-item>
              <el-descriptions-item label="成果名称">
                {{ infoview1.name }}
              </el-descriptions-item>
              <el-descriptions-item label="第一作者">
                {{ infoview1.firstAuthor }}
              </el-descriptions-item>
              <el-descriptions-item label="一级学科">
                {{ infoview1.discipline }}
              </el-descriptions-item>
              <el-descriptions-item label="成果形式">
                {{ infoview1.resultForm }}
              </el-descriptions-item>
              <el-descriptions-item label="成果来源">
                {{ infoview1.source }}
              </el-descriptions-item>
              <el-descriptions-item label="是否被领导签批">
                {{ infoview1.isApproved === 1?'是':'否' }}
              </el-descriptions-item>
              <el-descriptions-item label="签批领导">
                {{ infoview1.approvedLeader }}
              </el-descriptions-item>
              <el-descriptions-item label="是否被使用单位采纳">
                {{ infoview1.isAdopted === 1?'是':'否' }}
              </el-descriptions-item>
              <el-descriptions-item label="采纳部门">
                {{ infoview1.adoptedDepartment }}
              </el-descriptions-item>
              <el-descriptions-item label="采纳/签批时间">
                {{ infoview1.adoptionTime }}
              </el-descriptions-item>
              <el-descriptions-item label="级别">
                {{ infoview1.level }}
              </el-descriptions-item>
              <el-descriptions-item label="所属机构">
                {{ infoview1.institutionName }}
              </el-descriptions-item>
              <el-descriptions-item label="成果引用采纳情况">
                {{ infoview1.citationStatus }}
              </el-descriptions-item>
              <el-descriptions-item label="状态">
                <el-tag :type="infoview1.status | statusFilter">{{ infoview1.status }}</el-tag>
              </el-descriptions-item>
              <el-descriptions-item label="退回原因">
                {{ infoview1.reason }}
              </el-descriptions-item>
              <el-descriptions-item label="分数">
                <el-tag type="">{{ infoview1.score }}</el-tag>
              </el-descriptions-item>
              <el-descriptions-item label="备注">
                {{ infoview1.notes }}
              </el-descriptions-item>
            </el-descriptions>
          </el-collapse-item>
          <el-collapse-item name="2">
            <template slot="title">
              <div class="el-descriptions__title">量化分数</div>
            </template>
            <div style="margin-bottom: 10px;">
              <span>分数计算规则参考：</span>
              <el-link type="primary" :href="$FILE_PATH+'/file/量化细则图/学术论文计分规则可视化.pdf'" target="_blank">学术论文计分规则可视化</el-link>
              <br>
              <span>官方文件：</span>
              <el-link type="primary" :href="$FILE_PATH+'/file/量化细则图/湖北师范大学科研工作量化管理办法（修订版）.pdf'" target="_blank">湖北师范大学科研工作量化管理办法（修订版）</el-link>
              <el-switch
                v-model="thesis_source_form.manualScoreMode"
                active-text="手动填分"
                inactive-text="自动计分"
                style="float: right; margin-right: 20px;"
                @change="handleScoreModeChange"
              />
            </div>
            <el-table
              v-loading="sourceListLoading"
              :data="sourceList"
              element-loading-text="Loading"
              border
              fit
            >
              <el-table-column v-if="!thesis_source_form.manualScoreMode" align="center" label="一级类型" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.achievementType1 }}
                </template>
              </el-table-column>
              <el-table-column v-if="!thesis_source_form.manualScoreMode" align="center" label="二级类型" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.achievementType2 }}
                </template>
              </el-table-column>
              <el-table-column v-if="!thesis_source_form.manualScoreMode" align="center" label="三级类型" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.achievementType3 }}
                </template>
              </el-table-column>
              <el-table-column v-if="thesis_source_form.manualScoreMode" align="center" label="算分详情" min-width="200">
                <template slot-scope="scope">
                  {{ scope.row.Note }}
                </template>
              </el-table-column>
              <!-- 通用列 -->
              <el-table-column align="center" label="最终得分" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.finalValue }}
                </template>
              </el-table-column>
            </el-table>
          </el-collapse-item>
          <el-collapse-item name="3">
            <template slot="title">
              <div class="el-descriptions__title">作者信息</div>
            </template>
            <el-table
              v-loading="paperAuthorListLoading"
              :data="paperAuthorList"
              element-loading-text="Loading"
              border
              fit
            >
              <el-table-column align="center" label="工号" min-width="100">
                <template slot-scope="scope">
                  {{ (scope.row.authortype === '校内教师' || scope.row.authortype === '校内教师' || scope.row.authortype === '校内教师' || !scope.row.authortype) && scope.row.userAccount ? scope.row.userAccount : '无' }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="姓名" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.name }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="所属院系" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.dept }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="作者类型" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.authortype }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="考核系数" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.assessment }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="个人得分" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.pscore }}
                </template>
              </el-table-column>
            </el-table>
          </el-collapse-item>
          <el-collapse-item name="4">
            <template slot="title">
              <div class="el-descriptions__title">关联项目信息</div>
            </template>
            <el-table
              v-loading="paperProjectListLoading"
              :data="paperProjectList"
              element-loading-text="Loading"
              border
              fit
            >
              <el-table-column align="center" label="项目名称" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.projectName }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="项目负责人" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.head }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="署名单位" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.signedUnit }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="开始日期" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.startTime }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="结束日期" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.endTime }}
                </template>
              </el-table-column>
            </el-table>
          </el-collapse-item>
          <el-collapse-item name="5">
            <template slot="title">
              <div class="el-descriptions__title">附件信息</div>
            </template>
            <el-table
              v-loading="fileListLoading"
              :data="fileList"
              element-loading-text="Loading"
              border
              fit
            >
              <el-table-column type="index" align="center" label="序号" width="55" />
              <el-table-column align="left" label="文件名称" min-width="150">
                <template slot-scope="scope">
                  {{ scope.row.filename }}
                </template>
              </el-table-column>
              <el-table-column align="left" label="文件大小" min-width="150">
                <template slot-scope="scope">
                  <span v-if="scope.row.filesize / 1024 / 1024 < 1">{{ (scope.row.filesize / 1024).toFixed(2) + 'KB' }}</span>
                  <span v-else>{{ (scope.row.filesize / 1024 / 1024).toFixed(2) + 'MB' }}</span>
                </template>
              </el-table-column>
              <el-table-column align="left" label="上传时间" min-width="150">
                <template slot-scope="scope">
                  {{ scope.row.filedate }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="操作" width="150">
                <template slot-scope="scope">
                  <el-button
                    size="mini"
                    @click="downloadFile(scope.row)"
                  >
                    下载
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-collapse-item>
          <el-collapse-item name="6">
            <template slot="title">
              <div class="el-descriptions__title">审核记录</div>
            </template>
            <el-table
              v-loading="paperAuditListLoading"
              :data="paperAuditList"
              element-loading-text="Loading"
              border
              fit
            >
              <el-table-column type="index" align="center" label="序号" width="55" />
              <el-table-column align="center" label="审核员职位" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.auditerRole }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="审核员姓名" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.auditerName }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="项目状态变化" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.statusChange }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="审核意见" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.auditOpinion }}
                </template>
              </el-table-column>
              <el-table-column align="center" label="审核时间" min-width="100">
                <template slot-scope="scope">
                  {{ scope.row.auditerTime }}
                </template>
              </el-table-column>
            </el-table>
          </el-collapse-item>
        </el-collapse>
        <div slot="footer" class="dialog-footer">
          <el-button @click="infoview_dialog = false">关 闭</el-button>
        </div>
      </el-dialog>
      <el-dialog title="导出excel" :visible.sync="excel_dialog" width="60%">
        <el-alert
          title="请选择需要导出的数据"
          type="success"
          description="选择的数据为表头，未选择的数据将不会导出"
          :closable="false"
        />
        <div style="margin: 15px;">
          <el-checkbox v-model="checkAll" :indeterminate="isIndeterminate" @change="handleCheckAllChange">全选</el-checkbox>
          <div style="margin: 15px 0;" />
          <el-checkbox-group v-model="check_fields" @change="handleCheckedFieldsChange">
            <el-checkbox v-for="field in fields_list" :key="field" :label="field">{{ field }}</el-checkbox>
          </el-checkbox-group>
        </div>
        <!-- <el-alert
          title="请选择时间范围"
          type="success"
          description="选择导出数据的时间范围"
          :closable="false"
        /> -->
        <div slot="footer" class="dialog-footer">
          <el-button @click="excel_dialog = false">关 闭</el-button>
          <download-excel
            style="display:inline-block !important;margin-left:10px;"
            :data="EXCEL.DetailsForm"
            :fields="EXCEL.json_fields"
            :header="EXCEL.title"
            type="xls"
            name="咨询报告数据导出.xls"
            :fetch="createExportData"
            :before-generate="startDownload"
            :before-finish="finishDownload"
          >
            <!-- 上面可以自定义自己的样式，还可以引用其他组件button -->
            <el-button type="success" plain>确认导出</el-button>
          </download-excel>
        </div>
      </el-dialog>
    </div>
  </div>
</template>

<script>
import { getMyPaperListExport, getUserConsults, thesis_pass_yuanji, thesis_back_yuanji, get_thesis_author, get_file, getQulification } from '@/api/consult'
import { get_thesis_Audit } from '@/api/audit'
import { Message, Loading } from 'element-ui'
import { mapGetters } from 'vuex'

export default {
  filters: {
    statusFilter(status) {
      const statusMap = {
        草稿: 'info',
        待院级审核: '',
        被院级退回: 'warning',
        待校级审核: '',
        被校级退回: 'danger',
        审核通过: 'success'
      }
      return statusMap[status]
    }
  },
  data() {
    return {
      thesis_source_form: {
        manualScoreMode: false
      },
      search: {
        adoptedDepartment: '',
        adoptionTime: null,
        allAuthor: '',
        allAuthorName: '',
        approvedLeader: '',
        citationStatus: '',
        discipline: '',
        entered: '',
        enteredTime: null,
        firstAuthor: '',
        id: '',
        institution: '',
        institutionName: '',
        isAdopted: 0,
        isApproved: 0,
        level: '',
        name: '',
        reason: '',
        resultForm: '',
        score: '',
        source: '',
        status: ''
      },
      status: '待院级审核',
      infoview_dialog: false,
      paperList: null,
      paperListLoading: false,
      paperAuthorList: null,
      paperAuthorListLoading: false,
      paperAuditList: [],
      paperAuditListLoading: false,
      p1_size: 10,
      p1_total: 0,
      p1_page: 1,
      back_post: {
        id: '',
        reason: ''
      },
      infoview1: {},
      activeNames: ['1', '2', '3', '4', '5', '6'],
      excel_dialog: false,
      all_fields: {
        '采纳部门': 'adoptedDepartment',
        '采纳/签批时间': 'adoptionTime',
        '所有作者': 'allAuthorName',
        '签批领导': 'approvedLeader',
        '成果引用采纳情况': 'citationStatus',
        '一级学科': 'discipline',
        '录入人': 'enteredName',
        '第一作者': 'firstAuthor',
        '咨询报告ID': 'id',
        '所属机构': 'institutionName',
        '是否被使用单位采纳(0为否,1为是)': 'isAdopted',
        '是否被领导签批(0为否,1为是)': 'isApproved',
        '级别': 'level',
        '成果名称': 'name',
        '未通过原因': 'reason',
        '成果形式': 'resultForm',
        '量化分数': 'score',
        '成果来源': 'source',
        '审核结果': 'status'
      },
      fields_list: [
        '采纳部门',
        '采纳/签批时间',
        '所有作者',
        '签批领导',
        '成果引用采纳情况',
        '一级学科',
        '录入人',
        '第一作者',
        '咨询报告ID',
        '所属机构',
        '是否被使用单位采纳(0为否,1为是)',
        '是否被领导签批(0为否,1为是)',
        '级别',
        '成果名称',
        '未通过原因',
        '成果形式',
        '量化分数',
        '成果来源',
        '审核结果'
      ],
      check_fields: [],
      checkAll: false,
      isIndeterminate: false,
      EXCEL: {
        title: '测试表格',
        json_fields: null,
        DetailsForm: null
      },
      fileList: [],
      fileListLoading: false,
      sourceListLoading: false,
      sourceList: []
    }
  },
  computed: {
    ...mapGetters([
      'uid',
      'roles',
      'name',
      'dept'
    ]),
    YuanjiPaperPost() {
      return {
        pageNum: this.p1_page,
        pageSize: this.p1_size,
        ...this.search
      }
    }
  },
  watch: {
    search: {
      handler() {
        this.paperListLoading = true
        clearTimeout(this.searchTimeout)
        this.searchTimeout = setTimeout(() => {
          this.fetchPaperData()
          this.paperListLoading = false
        }, 1500)
      },
      deep: true // 启用深度监视，可监听对象内部属性变化
    }
  },
  created() {
    this.fetchPaperData()
  },
  methods: {
    // 处理切换模式
    handleScoreModeChange(value) {
      this.thesis_source_form.manualScoreMode = value
    },
    statusChange() {
      this.fetchPaperData()
    },
    fetchPaperData() {
      this.paperListLoading = true
      getUserConsults(this.YuanjiPaperPost).then(response => {
        if (response.code === 200) {
          this.paperList = response.data.list
          this.p1_total = response.data.total
          this.paperListLoading = false
        }
      })
    },
    p1_sizechange(newsize) {
      this.p1_size = newsize
      this.p1_page = 1
      this.fetchPaperData()
    },
    p1_currentchange(newpage) {
      this.p1_page = newpage
      this.fetchPaperData()
    },
    filterTag(value, row) {
      return row.status === value
    },
    thesis_back(row) {
      this.$prompt('请输入退回原因', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        inputPattern: /^.+$/,
        inputErrorMessage: '原因不能为空'
      }).then(({ value }) => {
        this.back_post.id = row.id
        this.back_post.reason = value
        thesis_back_yuanji(this.back_post).then(response => {
          if (response.code === 200) {
            Message.success('退回成功')
            this.fetchPaperData()
          }
        })
      }).catch(() => {
        Message.info('取消退回')
      })
    },
    thesis_pass(index, row) {
      this.$refs[`popoverpass-${index}`].doClose()
      thesis_pass_yuanji(row.id).then(response => {
        if (response.code === 200) {
          Message.success('通过成功')
          this.fetchPaperData()
        }
      })
    },
    open_infoview_dialog(row) {
      this.infoview_dialog = true
      this.infoview1 = JSON.parse(JSON.stringify(row))
      this.paperAuthorListLoading = true
      get_thesis_author(row.id).then(response => {
        if (response.code === 200) {
          this.paperAuthorList = response.data
          this.paperAuthorListLoading = false
        }
      })
      this.fileListLoading = true
      get_file(row.id).then(response => {
        if (response.code === 200) {
          this.fileList = response.data
          this.fileListLoading = false
        }
      })
      this.sourceListLoading = true
      getQulification(row.id).then(response => {
        if (response.code === 200) {
          this.sourceList = response.data
          this.sourceListLoading = false
        }
      })
      this.paperAuditListLoading = true
      get_thesis_Audit(row.id).then(response => {
        if (response.code === 200) {
          this.paperAuditList = response.data
          this.paperAuditListLoading = false
        }
      })
    },
    downloadFile(row) {
      var a = document.createElement('a')
      var event = new MouseEvent('click')
      // 确保文件路径正确拼接，处理fileupload文件夹的路径
      let fileUrl = row.fileurl
      if (!fileUrl.startsWith('https')) {
        // 如果不是完整URL，则拼接FILE_PATH
        if (fileUrl.startsWith('/')) {
          fileUrl = this.$FILE_PATH + fileUrl
        } else {
          fileUrl = this.$FILE_PATH + '/' + fileUrl
        }
      }
      a.href = fileUrl
      a.target = '_blank'
      a.dispatchEvent(event)
    },
    // 以下为数据导出
    handleCheckAllChange(val) {
      this.check_fields = val ? this.fields_list : []
      this.isIndeterminate = false
      this.EXCEL.json_fields = JSON.parse(JSON.stringify(this.all_fields, this.check_fields))
    },
    handleCheckedFieldsChange(value) {
      const checkedCount = value.length
      this.checkAll = checkedCount === this.fields_list.length
      this.isIndeterminate = checkedCount > 0 && checkedCount < this.fields_list.length
      this.EXCEL.json_fields = JSON.parse(JSON.stringify(this.all_fields, this.check_fields))
    },
    async createExportData() {
      return await getMyPaperListExport(this.YuanjiPaperPost).then(response => {
        if (response.code === 200) {
          if (response.data.list.length === 0) {
            Message.warning('返回数据为空，导出失败！')
            this.loadingInstance.close()
          }
          return response.data.list
        }
      })
    },
    startDownload() {
      this.excel_dialog = false
      this.loadingInstance = Loading.service({ text: '正在导出...' })
    },
    finishDownload() {
      setTimeout(() => {
        this.loadingInstance.close()
      }, 1000)
    }
  }
}
</script>

<style lang="scss">
.el-form{
  margin-left: 40px;
  .el-input,.el-select{
    width: 300px;
  }
}
@media screen and (max-width:600px) {
  .el-dialog{
    width: 100% !important;
  }
  .el-form{
    margin-left: 25px;
  }
}
</style>
